#pragma once

#include <string>


namespace evm { namespace base64 {

using namespace std;

string encode(const char* buf, size_t len);

/* Returns true when decoded successfully, otherwise returns false.
 * If returns true, buf points to decoded data, and len is its length.
 * User should be delete [] buf after use. */
bool decode(const string& encoded_data, char*& buf, size_t& len);

// Returns encoded data.
inline string encode(const string& raw_data) {
    return encode(raw_data.c_str(), raw_data.size());
}

/* Returns decoded data.
 * Throw invalid_argument when error. */
string decode(const string& encoded_data);

}}
